package com.cal.utms.entity;

import java.io.Serializable;

import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * The persistent class for the fund database table.
 * 
 */
@Entity
@Table(name = "fund")
@NamedQuery(name = "Fund.findAll", query = "SELECT f FROM Fund f")
public class Fund implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(unique = true, nullable = false)
	private int id;

	@Column(name = "AUDIT_FEE", precision = 10, scale = 4)
	private BigDecimal auditFee;

	@Column(name = "AUDIT_FEE_TYPE", length = 45)
	private String auditFeeType;

	@Column(length = 45)
	private String category;

	@Column(name = "CDS_ACCOUNT", length = 45)
	private String cdsAccount;

	@Column(name = "CONFIRMED_BY", length = 60)
	private String confirmedBy;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CONFIRMED_DATE")
	private Date confirmedDate;

	@Column(name = "CREATED_BY", length = 60)
	private String createdBy;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATED_DATE")
	private Date createdDate;

	@Column(name = "CUSTODIAN_ACCOUNT", length = 45)
	private String custodianAccount;

	@Column(name = "CUSTODIAN_FEE", precision = 10, scale = 4)
	private BigDecimal custodianFee;

	@Column(name = "CUSTODIAN_FEE_TYPE", length = 45)
	private String custodianFeeType;

	@Column(length = 600)
	private String description;

	@Column(name = "FUND_CODE", length = 45)
	private String fundCode;

	@Column(name = "FUND_NAME", length = 60)
	private String fundName;

	@Column(name = "MANAGEMENT_FEE", precision = 10, scale = 4)
	private BigDecimal managementFee;

	@Column(name = "MANAGEMENT_FEE_TYPE", length = 45)
	private String managementFeeType;

	@Column(name = "MAX_PERCENTAGE", precision = 10, scale = 4)
	private BigDecimal maxPercentage;

	@Column(name = "MIN_PERCENTAGE", precision = 10, scale = 6)
	private BigDecimal minPercentage;

	@Column(name = "MIN_UNIT_HOLDERS")
	private int minUnitHolders;

	@Column(name = "MODIFIED_BY", length = 60)
	private String modifiedBy;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "MODIFIED_DATE")
	private Date modifiedDate;

	@Column(precision = 10, scale = 4)
	private BigDecimal opc;

	@Column(name = "OTHER_FEE_ANNUAL", precision = 10, scale = 4)
	private BigDecimal otherFeeAnnual;

	@Column(name = "OTHER_FEE_MONTHLY", precision = 10, scale = 4)
	private BigDecimal otherFeeMonthly;

	@Column(name = "OTHER_FEE_PERCENT", precision = 10, scale = 4)
	private BigDecimal otherFeePercent;

	@Column(name = "TRUSTEE_FEE", precision = 10, scale = 4)
	private BigDecimal trusteeFee;

	@Column(name = "TRUSTEE_FEE_TYPE", length = 45)
	private String trusteeFeeType;

	@Column(name = "VALUATION_METHOD", length = 45)
	private String valuationMethod;

	@Column(name = "UNIT_VALUE", precision = 20, scale = 4)
	private BigDecimal unitValue;

	@Column(name = "PORTFOLIO", precision = 20, scale = 4)
	private BigDecimal portfolio;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "UPDATED_DATE")
	private Date updateDate;
	// bi-directional many-to-one association to CustodianContactPerson
	@OneToMany(mappedBy = "fund", fetch = FetchType.EAGER)
	@Fetch(value = FetchMode.SUBSELECT)
	private List<CustodianContactPerson> custodianContactPersons;

	// uni-directional many-to-one association to Custodian
	@ManyToOne
	@JoinColumn(name = "CUSTODIAN_ID")
	private Custodian custodian;

	// uni-directional many-to-many association to DealType
	@ManyToMany(fetch = FetchType.EAGER)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinTable(name = "fund_deal_type", joinColumns = { @JoinColumn(name = "FUND_ID") }, inverseJoinColumns = { @JoinColumn(name = "DEAT_TYPE_ID", nullable = false) })
	private List<DealType> dealTypes;

	// uni-directional many-to-many association to Issure
	@ManyToMany(fetch = FetchType.EAGER)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinTable(name = "fund_issuer_map", joinColumns = { @JoinColumn(name = "FUND_ID", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "ISSUER_ID", nullable = false) })
	private List<IssuerType> issureTypes;

	// uni-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name = "FUND_MANAGER")
	private User fundManager;

	// bi-directional many-to-one association to FundInstrumentMap
	@OneToMany(mappedBy = "fund", fetch = FetchType.EAGER)
	@Fetch(value = FetchMode.SUBSELECT)
	private List<FundInstrumentMap> fundInstrumentMaps;

	@Column(name = "STATUS", length = 10)
	private String status;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "TRUST_DEED_DATE")
	private Date trustDeedDate;

	public Fund() {
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public BigDecimal getAuditFee() {
		return this.auditFee;
	}

	public void setAuditFee(BigDecimal auditFee) {
		this.auditFee = auditFee;
	}

	public String getAuditFeeType() {
		return this.auditFeeType;
	}

	public void setAuditFeeType(String auditFeeType) {
		this.auditFeeType = auditFeeType;
	}

	public String getCategory() {
		return this.category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getCdsAccount() {
		return this.cdsAccount;
	}

	public void setCdsAccount(String cdsAccount) {
		this.cdsAccount = cdsAccount;
	}

	public String getCustodianAccount() {
		return this.custodianAccount;
	}

	public void setCustodianAccount(String custodianAccount) {
		this.custodianAccount = custodianAccount;
	}

	public BigDecimal getCustodianFee() {
		return this.custodianFee;
	}

	public void setCustodianFee(BigDecimal custodianFee) {
		this.custodianFee = custodianFee;
	}

	public String getCustodianFeeType() {
		return this.custodianFeeType;
	}

	public void setCustodianFeeType(String custodianFeeType) {
		this.custodianFeeType = custodianFeeType;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getFundCode() {
		return this.fundCode;
	}

	public void setFundCode(String fundCode) {
		this.fundCode = fundCode;
	}

	public String getFundName() {
		return this.fundName;
	}

	public void setFundName(String fundName) {
		this.fundName = fundName;
	}

	public BigDecimal getManagementFee() {
		return this.managementFee;
	}

	public void setManagementFee(BigDecimal managementFee) {
		this.managementFee = managementFee;
	}

	public String getManagementFeeType() {
		return this.managementFeeType;
	}

	public void setManagementFeeType(String managementFeeType) {
		this.managementFeeType = managementFeeType;
	}

	public BigDecimal getMaxPercentage() {
		return this.maxPercentage;
	}

	public void setMaxPercentage(BigDecimal maxPercentage) {
		this.maxPercentage = maxPercentage;
	}

	public BigDecimal getMinPercentage() {
		return this.minPercentage;
	}

	public void setMinPercentage(BigDecimal minPercentage) {
		this.minPercentage = minPercentage;
	}

	public int getMinUnitHolders() {
		return this.minUnitHolders;
	}

	public void setMinUnitHolders(int minUnitHolders) {
		this.minUnitHolders = minUnitHolders;
	}

	public BigDecimal getOpc() {
		return this.opc;
	}

	public void setOpc(BigDecimal opc) {
		this.opc = opc;
	}

	public BigDecimal getOtherFeeAnnual() {
		return this.otherFeeAnnual;
	}

	public void setOtherFeeAnnual(BigDecimal otherFeeAnnual) {
		this.otherFeeAnnual = otherFeeAnnual;
	}

	public BigDecimal getOtherFeeMonthly() {
		return this.otherFeeMonthly;
	}

	public void setOtherFeeMonthly(BigDecimal otherFeeMonthly) {
		this.otherFeeMonthly = otherFeeMonthly;
	}

	public BigDecimal getOtherFeePercent() {
		return this.otherFeePercent;
	}

	public void setOtherFeePercent(BigDecimal otherFeePercent) {
		this.otherFeePercent = otherFeePercent;
	}

	public BigDecimal getTrusteeFee() {
		return this.trusteeFee;
	}

	public void setTrusteeFee(BigDecimal trusteeFee) {
		this.trusteeFee = trusteeFee;
	}

	public String getTrusteeFeeType() {
		return this.trusteeFeeType;
	}

	public void setTrusteeFeeType(String trusteeFeeType) {
		this.trusteeFeeType = trusteeFeeType;
	}

	public String getValuationMethod() {
		return this.valuationMethod;
	}

	public void setValuationMethod(String valuationMethod) {
		this.valuationMethod = valuationMethod;
	}

	public List<CustodianContactPerson> getCustodianContactPersons() {
		return this.custodianContactPersons;
	}

	public void setCustodianContactPersons(List<CustodianContactPerson> custodianContactPersons) {
		this.custodianContactPersons = custodianContactPersons;
	}

	public CustodianContactPerson addCustodianContactPerson(CustodianContactPerson custodianContactPerson) {
		getCustodianContactPersons().add(custodianContactPerson);
		custodianContactPerson.setFund(this);

		return custodianContactPerson;
	}

	public CustodianContactPerson removeCustodianContactPerson(CustodianContactPerson custodianContactPerson) {
		getCustodianContactPersons().remove(custodianContactPerson);
		custodianContactPerson.setFund(null);

		return custodianContactPerson;
	}

	public Custodian getCustodian() {
		return this.custodian;
	}

	public void setCustodian(Custodian custodian) {
		this.custodian = custodian;
	}

	public List<DealType> getDealTypes() {
		return this.dealTypes;
	}

	public void setDealTypes(List<DealType> dealTypes) {
		this.dealTypes = dealTypes;
	}

	public List<IssuerType> getIssureTypes() {
		return issureTypes;
	}

	public void setIssureTypes(List<IssuerType> issureTypes) {
		this.issureTypes = issureTypes;
	}

	public User getFundManager() {
		return this.fundManager;
	}

	public void setFundManager(User fundManager) {
		this.fundManager = fundManager;
	}

	public List<FundInstrumentMap> getFundInstrumentMaps() {
		return this.fundInstrumentMaps;
	}

	public void setFundInstrumentMaps(List<FundInstrumentMap> fundInstrumentMaps) {
		this.fundInstrumentMaps = fundInstrumentMaps;
	}

	public FundInstrumentMap addFundInstrumentMap(FundInstrumentMap fundInstrumentMap) {
		getFundInstrumentMaps().add(fundInstrumentMap);
		fundInstrumentMap.setFund(this);

		return fundInstrumentMap;
	}

	public FundInstrumentMap removeFundInstrumentMap(FundInstrumentMap fundInstrumentMap) {
		getFundInstrumentMaps().remove(fundInstrumentMap);
		fundInstrumentMap.setFund(null);

		return fundInstrumentMap;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getConfirmedBy() {
		return confirmedBy;
	}

	public void setConfirmedBy(String confirmedBy) {
		this.confirmedBy = confirmedBy;
	}

	public Date getConfirmedDate() {
		return confirmedDate;
	}

	public void setConfirmedDate(Date confirmedDate) {
		this.confirmedDate = confirmedDate;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public String getModifiedBy() {
		return modifiedBy;
	}

	public void setModifiedBy(String modifiedBy) {
		this.modifiedBy = modifiedBy;
	}

	public Date getModifiedDate() {
		return modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		this.modifiedDate = modifiedDate;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public BigDecimal getUnitValue() {
		return unitValue;
	}

	public void setUnitValue(BigDecimal unitValue) {
		this.unitValue = unitValue;
	}

	public BigDecimal getPortfolio() {
		return portfolio;
	}

	public void setPortfolio(BigDecimal portfolio) {
		this.portfolio = portfolio;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public Date getTrustDeedDate() {
		return trustDeedDate;
	}

	public void setTrustDeedDate(Date trustDeedDate) {
		this.trustDeedDate = trustDeedDate;
	}

}